﻿using System;
using System.Net;
using System.Windows;
using System.Linq;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Collections.ObjectModel;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ServiceModel.DomainServices.Client;
using InsuranceAdjuster.Web.Models;
using System.Runtime.Serialization;
using InsuranceAdjuster.OccasionallyConnected;
using System.Collections.Generic;

namespace InsuranceAdjuster.Web.Models {

    [DataContract]
    public class VehicleInformation : IEntity {
        [DataMember]
        public List<StandardVehicleImage> StandardVehicleImages { get; set; }
        [DataMember]
        public Guid EntityGuid { get { return new Guid("ECC5E4E3-E507-4F62-953A-E4AF21ED3F17"); } set { return; } }
        [DataMember]
        public DateTime EntityVersion { get; set; }

        public VehicleInformation() {
            EntityGuid = new Guid("ECC5E4E3-E507-4F62-953A-E4AF21ED3F17");
            StandardVehicleImages = new List<StandardVehicleImage>();
        }

        internal void Add(StandardVehicleImage vehicle) {
            this.StandardVehicleImages.Add(vehicle);
            this.EntityVersion = DateTime.Now;
        }

        internal void Delete(StandardVehicleImage vehicle) {
            try {
                var FindResult = StandardVehicleImages.FirstOrDefault(x => x.EntityGuid == vehicle.EntityGuid);
                StandardVehicleImages.Remove(FindResult);
                this.EntityVersion = DateTime.Now;
            } catch (Exception) {
                
            }
        }

        internal void Update(StandardVehicleImage vehicle) {
            Delete(vehicle);
            Add(vehicle);
        }
    }
}
